#pragma once


/* Standard C++ includes */

#include <iostream>
#include <sstream>
#include <cv.h>
#include <highgui.h>
#include "Frame.h"
//#include <isstream>

//#include "mysql_connection.h"

//#include <windows.h>
//#include <sql.h>
/*#include <sql.h>
#include <sqlext.h>
#include <mysql++.h>
#include <iostream>*/

/*
#include <string>
#include <cppconn/driver.h>
#include <cppconn/exception.h>
#include <cppconn/resultset.h>
#include <cppconn/prepared_statement.h>*/

//http://dev.mysql.com/tech-resources/articles/mysql-connector-cpp.html
//http://dev.mysql.com/doc/refman/5.1/en/connector-cpp-apps-windows-visual-studio.html#connector-cpp-application-build-dynamic
#include <my_global.h>
#include <mysql.h>
#include <stdio.h>
using namespace std;
class DBConnect
{
private:
	char* username;
	char* password;
	char* dbName;
	char* server;
	
//	mysqlpp::Connection* conn;
	/*sql::Connection* conn;
	sql::Driver *driver;
	
	sql::Statement *stmt;
	sql::PreparedStatement *prep_stmt;*/

    //sql::ResultSet *res;
    MYSQL *conn;
    MYSQL_RES *result;
    MYSQL_ROW row;
    
    MYSQL_STMT *stmt;
    char *sql;



  


public:
	DBConnect(char* server, char* dbName, char* userName, char* password);	
	bool connect();
	void disconnect();
	
	MYSQL* getConnection();
	~DBConnect(void);
	
	void storeMovingImage(char* address,IplImage* image,time_t* time);
	vector<IplImage*> loadByCameraDate(char* ipAddrss,time_t* dateTime);
	//vector<IplImage*> loadByDate(time_t* dateTime);
	vector<int> loadImageIDByDate(time_t* dateTime);
	 vector<int> loadImageIDByCameraDate(char* ipAddrss,time_t* dateTime);
	  vector<int> loadImageIDByCameraDuration(char* ipAddrss,int dateTimeFromSecFrom70,int dateTimeToSecFrom70);
	 
    vector<int> loadImageIDWithMatchIdZero();
	IplImage* loadImageCameraIPById(char* cameraIP,int* secFrom70, int id);
	IplImage* loadImageById(int id);
	//string getSerializedSIFTFeatures(float* siftFeatures,int dimentionsLength);	
	//float* getDeSeraializedSIFTFeatures(const char* str, int length);
	
	//bool storeSerializedSIFTFeatures(float* siftFeatures,int dimentionsLength);
	//float* retriveSerializedSIFTFeatures(int id);
};
